﻿#include "InstructionTurnTableConnect.h"

#include "ScriptRunner.h"
#include "TurnTableCodec.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionTurnTableConnect,ScriptInstruction::Instruction_TurnTable_Connect,&InstructionTurnTableConnect::fromByteArray1);

InstructionTurnTableConnect::InstructionTurnTableConnect()
{
  instructionFlag = Instruction_TurnTable_Connect;
}

InstructionTurnTableConnect::InstructionTurnTableConnect(InstructionTurnTableConnect const& instructionTurnTableConnect)
{
  *this=instructionTurnTableConnect;
}

InstructionTurnTableConnect& InstructionTurnTableConnect::operator=(InstructionTurnTableConnect const & instructionTurnTableConnect)
{
  *(ScriptInstruction*)this=instructionTurnTableConnect;
  return *this;
}

InstructionTurnTableConnect::~InstructionTurnTableConnect()
{}

void InstructionTurnTableConnect::run()
{
  scriptRunner->sendInstruction(deviceId,TurnTableCodec::TurnTable_Connect);
//  StateChecker<TurnTableCodec::ConnectionState, TurnTableConnectionStateManager>::next_ifConditionReached(&TurnTableConnectionStateManager::getTurnTableConnectionState, turnTableConnectionStateManager, TurnTableCodec::State_Connected, scriptRunner->getTime_connectTimeOut(),scriptRunner);
}

QString InstructionTurnTableConnect::toString()
{
  return QStringLiteral("连接转台");
}

QByteArray InstructionTurnTableConnect::toByteArray()
{
  return ScriptInstruction::toByteArray();
}

ScriptInstruction* InstructionTurnTableConnect::fromByteArray1(char * const src,int size,int * offset)
{
  (void)src;
  (void)size;
  (void)offset;
  return new InstructionTurnTableConnect();
}
